﻿////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2009 Daniel F. Hanson
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
////////////////////////////////////////////////////////////////////////////////

using System;

namespace SilverLua.Runtime
{
   /// <summary>
   /// Changes the name that is exposed to SilverLua. Note that if you are using
   /// another attribute to expose a class or method, you can use the overload
   /// of the constructor to change the exposed name. This attribute is for
   /// members that are already exposed.
   /// </summary>
   [AttributeUsage(AttributeTargets.Constructor |
                   AttributeTargets.Field |
                   AttributeTargets.Method |
                   AttributeTargets.Property,
                   AllowMultiple = true)]
   public class LuaRenameAttribute : Attribute
   {
      internal string Rename { get; private set; }
      
      /// <summary>
      /// Gets or sets the name of the parent table that will contain this
      /// class or member. If unset, this will be added to the global table.
      /// </summary>
      public string Parent { get; set; }
      
      /// <summary>
      /// Gets or sets the name of the environment to expose this type or class.
      /// Use multiple LuaExpose attributes if you want to expose to multiple
      /// environments. If unset, this will be added to every environment of the
      /// VM.
      /// </summary>
      public string Environment { get; set; }

      /// <summary>
      /// Default constructor.
      /// </summary>
      public LuaRenameAttribute()
      {
         Rename = null;
         Parent = null;
         Environment = null;
      }

      /// <summary>
      /// Constructor. Used to provide a different name to use in SilverLua
      /// scripts. Required for overloaded constructors and methods.
      /// </summary>
      /// <param name="name">The name exposed to SilverLua for this type or member</param>
      public LuaRenameAttribute(string name)
      {
         Rename = name;
         Parent = null;
         Environment = null;
      }
   }
}